package design_pattern.factory.reflectFactory;


import java.util.Scanner;

/**
 * @version 1.0.0
 * Created by cyd on 2022-06-06 15:04:48
 * @ClassName : design_pattern.factory.reflectFactory.Client
 * @Description : 客户端
 */
public class Client {
    public static void main(String[] args) throws Exception {

        Scanner scanner = new Scanner(System.in);

        System.out.println("请输入第1个数字：");
        int numberA = scanner.nextInt();

        System.out.println("请输入操作符：");
        // design_pattern.factory.reflectFactory.OperationAdd
        // design_pattern.factory.reflectFactory.OperationMul
        String flag = scanner.next();

        System.out.println("请输入第2个数字：");
        int numberB = scanner.nextInt();

        Operation operation = OperationFactory.getInstance(flag);
        operation.setNumberA(numberA);
        operation.setNumberB(numberB);

        int result = operation.operate();
        System.out.println("结果为：" + result);
    }
}
